package org.hawk.gwtppc.webtest.tests.constructorsuite;

import java.lang.reflect.Constructor;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.TypeVariable;
import java.lang.reflect.WildcardType;
import java.util.List;

import org.hawk.gwtppc.webtest.common.Asserts;
import org.hawk.gwtppc.webtest.common.Test;
import org.hawk.gwtppc.webtest.tests.mock.GenericClassMock;

public class GetTypeParametersTest implements Test {

	@SuppressWarnings("rawtypes")
	public void run() throws Throwable {
		TypeVariable<Constructor<GenericClassMock>>[] vars1 = GenericClassMock.class.getDeclaredConstructor(List[].class).getTypeParameters();
		Asserts.assertEquals(vars1.length, 1);
		Asserts.assertEquals(vars1[0].getName(), "J");
		Asserts.assertEquals(vars1[0].getBounds().length, 2);
		
		ParameterizedType b1 = (ParameterizedType) vars1[0].getBounds()[0];
		Asserts.assertEquals(b1.getRawType(), List.class);
		Asserts.assertEquals(b1.getActualTypeArguments().length, 1);
		WildcardType w1 = (WildcardType) b1.getActualTypeArguments()[0];
		Asserts.assertEquals(w1.getLowerBounds().length, 0);
		Asserts.assertEquals(w1.getUpperBounds().length, 1);
		Asserts.assertEquals(w1.getUpperBounds()[0], Object.class);
	}

	public String getName() {
		return "getTypeParameters()";
	}

}
